package itheima.com.Day15.socketdemo8;

import java.io.*;
import java.net.Socket;

public class Client {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("127.0.0.1",10000);

        //先从本地读取出来
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("Day15\\src\\Client\\1.jpg"));

        BufferedOutputStream bos = new BufferedOutputStream(socket.getOutputStream());
        //将本地的数据读取到网络中
        int b;
        while ((b=bis.read())!=-1){
            bos.write(b);
        }
        //暂时关闭服务器
        socket.shutdownOutput();

        BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        String line;
        while ((line=br.readLine())!=null){
            System.out.println(line);
        }
        socket.close();
        bis.close();
        br.close();

    }
}
